﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AvalonEdit;
using System.Reflection;

namespace WpfApplication1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {


            public MainWindow()
        {
            InitializeComponent();
        }
        EditWindow ew = new EditWindow();
        private void button_Click(object sender, RoutedEventArgs e)
        {
            ew.Show();
        }


        private void test()
        {
            ew.cl.objRemote.Invoke("GetTime", null);
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            List<double[]> MeasureWidth=new List<double[]>(), MeasureLenth = new List<double[]>()
                , MeasureHeight = new List<double[]>(), HTGrabP = new List<double[]>()
                , BoxCornerCoord = new List<double[]>(), ObjectType = new List<double[]>(),
                StandByResult0 = new List<double[]>(), StandByResult1 = new List<double[]>()
                , StandByResult2 = new List<double[]>(), StandByResult3 = new List<double[]>();

            MeasureWidth.Add(new double[] { Convert.ToDouble(tb1.Text) });


            object[] mm=TraRes(MeasureWidth, MeasureLenth, MeasureHeight, HTGrabP, BoxCornerCoord, ObjectType
                , StandByResult0, StandByResult1, StandByResult2, StandByResult3);

            tb2.Clear();
            for (int i = 0; i < mm.Length; i++)
            {
                tb2.AppendText(mm[i].ToString()+"\r\n");
            }

        }



        private object[] TraRes(List<double[]> MeasureWidth, List<double[]> MeasureLenth
            , List<double[]> MeasureHeight, List<double[]> HTGrabP
            , List<double[]> BoxCornerCoord, List<double[]> ObjectType
            , List<double[]> StandByResult0, List<double[]> StandByResult1
            , List<double[]> StandByResult2, List<double[]> StandByResult3)
        {
            object[] objArray = new object[10];
            objArray[0] = MeasureWidth;
            objArray[1] = MeasureLenth;
            objArray[2] = MeasureHeight;
            objArray[3] = HTGrabP;
            objArray[4] = BoxCornerCoord;
            objArray[5] = ObjectType;
            objArray[6] = StandByResult0;
            objArray[7] = StandByResult1;
            objArray[8] = StandByResult2;
            objArray[9] = StandByResult3;
           return (object[])ew.cl.objRemote.Invoke("ResultMessage", objArray);
        }
        private object[] RobotRequ(string str,string num,int[] Array)
        {
            object[] objArray = new object[3];
            objArray[0] = str;
            objArray[1] = num;
            objArray[2] = Array;
            return (object[])ew.cl.objRemote.Invoke("RobotRequest", objArray);
        }




        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            ew.Close();
        }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            ew.cl.InitializeDynamic();
        }
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            ew.cl.UnLoad();
        }
    }
}
